from likeshop_api_project.api.login_api import login_model
from likeshop_api_project.base.mybase import Tools


# 取消未支付订单
class get_cancel_model(Tools):
    path = '/api/order/cancel'

    def get_cancel_action(self, orderid, hd):
        get_cancel_data = {
            "id": orderid
        }
        cancel = self.huihua.post(url=self.hosturl+self.path, data=get_cancel_data, headers=hd)
        return cancel.json()


if __name__ == '__main__':
    import requests

    s = requests.session()
    reg = login_model(huihua=s)
    msg = reg.login_action(account="13356786546", password="rr98765", client=2)
    # print(msg)
    get_token = msg["data"]["token"]
    # print(get_token)
    hd = {"token": get_token}

    cancel = get_cancel_model(huihua=s)
    msg = cancel.get_cancel_action(orderid=342, hd=hd)
    print(msg)
